<form id="create-request-form" role="form" data-toggle="validator" method="POST" action="">

    {if condition="isset($material)"}
    <!-- 已指定物料ID的情况 -->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">物料信息:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="alert alert-info">
                <p><strong>物料名称：</strong>{$material.name}</p>
                <p><strong>物料编码：</strong>{$material.code}</p>
                <p><strong>当前库存：</strong><span class="text-danger"><strong>{$material.stock} {$material.unit}</strong></span></p>
                <p><strong>最小库存：</strong>{$material.min_stock} {$material.unit}</p>
                <p><strong>建议采购：</strong><span class="text-success"><strong>{$suggestedQty} {$material.unit}</strong></span></p>
            </div>
            <input type="hidden" name="row[material_id]" value="{$material.id}">
        </div>
    </div>
    {else /}
    <!-- 未指定物料ID的情况，显示选择列表 -->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择物料:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-material_id" class="form-control selectpicker" name="row[material_id]" data-live-search="true" required>
                <option value="">请选择物料</option>
                {volist name="materials" id="mat"}
                <option value="{$mat.id}" data-stock="{$mat.stock}" data-min-stock="{$mat.min_stock}" data-unit="{$mat.unit}">
                    {$mat.name} ({$mat.code}) - 库存: {$mat.stock} {$mat.unit}
                </option>
                {/volist}
            </select>
        </div>
    </div>
    {/if}

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择供应商:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-supplier_id" class="form-control selectpicker" name="row[supplier_id]" data-live-search="true" required>
                <option value="">请选择供应商</option>
                {volist name="suppliers" id="supplier"}
                <option value="{$supplier.id}">{$supplier.name} - {$supplier.contact_person} - {$supplier.phone}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">申请数量:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-request_quantity" class="form-control" name="row[request_quantity]" type="number" step="0.01" min="0" value="{$suggestedQty|default=0}" placeholder="请输入申请数量" required>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">优先级:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-priority" class="form-control" name="row[priority]">
                <option value="1">低</option>
                <option value="2" selected>中</option>
                <option value="3">高</option>
                <option value="4">紧急</option>
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">备注说明:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-notes" class="form-control" rows="3" name="row[notes]" placeholder="请输入采购备注说明"></textarea>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed">提交采购申请</button>
            <button type="reset" class="btn btn-default btn-embossed">重置</button>
        </div>
    </div>

</form>
